<!--
 * @Author: taoke
 * @Date: 2022-04-28 16:02:05
 * @LastEditors: taoke
 * @LastEditTime: 2022-05-11 16:57:31
 * @Description:
 * @FilePath: \yunying-sys-cli4\src\components\partner\invitedRecord\topSearch.vue
-->
<template>
  <div id="mTopSearch">
    <div class="search-box">
      <el-form
        ref="ruleForm"
        :inline="true"
        :model="formInline"
        class="demo-form-inline"
      >
        <el-form-item label="邀请人大鹏号" prop="search">
          <el-input
            v-model="formInline.search"
            placeholder="请输入大鹏号/手机号"
            clearable
          >
          </el-input>
        </el-form-item>
        <el-form-item label="时间" prop="createTime">
          <el-date-picker
            v-model="formInline.createTime"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
            value-format="yyyy-MM-dd HH:mm:ss"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="当前订单状态" prop="orderStatus">
          <el-select v-model="formInline.orderStatus" clearable>
            <el-option
              v-for="item in orderStatusList"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="被邀请人大鹏号" prop="invitedDPAccount">
          <el-input
            v-model="formInline.invitedDPAccount"
            placeholder="请输入被邀请人大鹏号"
            clearable
          >
          </el-input>
        </el-form-item>
        <el-form-item class="s-btn">
          <el-button
            type="success"
            icon="el-icon-search"
            @click="toSearch('ruleForm')"
          >
            查询
          </el-button>
          <el-button type="success" plain @click="reset">
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'mTopSearch',
  msg: '合伙人邀请记录-顶部搜索',
  props: {
    formInline: {
      type: Object,
      default: function() {
        return {
          search: '', //大鹏号
          startTime: '', // 开始日期
          endTime: '', // 结束日期
          orderStatus: '', // 当前订单状态
          invitedDPAccount: '', //被邀请人大鹏号
          createTime: []
        }
      }
    }
  },
  data() {
    return {
      orderStatusList: [
        { dictLabel: '全部', dictValue: '' },
        { dictLabel: '已下单支付', dictValue: 'FORMAL' }
      ]
    }
  },
  methods: {
    /* 搜索 */
    toSearch(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('toSearch')
        } else {
          return false
        }
      })
    },
    /* 重置 */
    reset() {
      this.$refs['ruleForm'].resetFields()
    }
  },
  watch: {
    'formInline.createTime': {
      handler(newVal, oldVal) {
        if (newVal && newVal.length > 1) {
          this.formInline.startTime = newVal[0]
          this.formInline.endTime = newVal[1]
        } else {
          this.formInline.startTime = ''
          this.formInline.endTime = ''
        }
      },
      deep: true
    }
  }
}
</script>

<style lang="less">
#mTopSearch {
  .long-input {
    .el-input--suffix {
      width: 130px !important;
    }
  }

  label.el-form-item__label {
    /*width: 100px !important;*/
  }
}
</style>
